package com.ojoin.trade.common_core.web.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.utils.LogUtils;
import com.ojoin.trade.common.web.dao.BaseDao;
import com.ojoin.trade.common.web.service.impl.BaseServiceImpl;
import com.ojoin.trade.common_core.web.dao.TbBranchDao;
import com.ojoin.trade.common_core.web.domain.TbBranch;
import com.ojoin.trade.common_core.web.service.BranchBaseService;

@Service
public class BranchBaseServiceImpl extends BaseServiceImpl<TbBranch> implements
		BranchBaseService {

	@Autowired
	private TbBranchDao dao;
	
	@Override
	protected BaseDao<TbBranch> getBaseDao() {
		return dao;
	}

	@Cacheable(value = "enumCache",key="#area_id.concat(#bankname)")
	@Override
	public List<TbBranch> queryBankBranch(String area_id, String bankname)
			throws BusinessException {
		LogUtils.getT0loanLog().info("查询指定地区->" + area_id + "银行->" + bankname + "的所有下级支行.");
		return ((TbBranchDao) this
				.getBaseDao()).queryBankBranch(area_id, bankname);
	}
	
	@Cacheable(value = "enumCache",key="#branchNo")
	@Override
	public String queryDisplayBranchNo(String branchNo){
		TbBranch q=new TbBranch();
		q.setUnionBankNo(branchNo);
		TbBranch  one=dao.selectOne(q);
		if(null!=one){
			return one.getName();
		}
		return null;
	}

}
